package com.devops.admin.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.devops.admin.model.DOSRelease;
import com.devops.admin.model.TableResult;
import com.devops.admin.po.*;
import com.devops.admin.vo.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassNem DOSReleaseService
 * @Description TODO
 * @Author heyabo
 * @Date 2022/3/22 14:47
 * @Version 1.0
 **/
public interface DOSReleaseService extends IService<DOSRelease> {

    /**
     * @Author heyabo
     * @Description 查询release列表
     * @Date 14:32 2022/3/24
     * @Param [releaseVo]
     * @return com.devops.admin.model.TableResult<com.devops.admin.po.DOSProjectPo>
     **/
    TableResult<DOSReleasePo> getReleases(DOSReleaseVo releaseVo, DOSPageVo pageVo);


    /**
     * @Author heyabo
     * @Description 查询values
     * @Date 2022/4/12
     * @Param [valuesVo]
     * @return java.lang.String
     **/
    DOSValuePo getValues(DOSReleaseValuesVo valuesVo);
    /**
     * @Author heyabo
     * @Description 查询release列表
     * @Date 14:32 2022/3/24
     * @Param [releaseVo]
     * @return com.devops.admin.model.TableResult<com.devops.admin.po.DOSProjectPo>
     **/
    List<DOSReleasePo> getReleases(DOSReleaseVo releaseVo);

    /**
     * 根据id获取单个release的详情
     * @param releaseId
     * @return
     */
    DOSReleasePo getReleaseDetailById(Integer releaseId);

    //新增
    DOSHelmOperationPo installReleaseByRepoChart(DOSReleaseParamVo param);
    DOSHelmOperationPo upgradeReleaseByRepoChart(DOSReleaseParamVo param);
    DOSHelmOperationPo historyRelease(DOSReleaseParamVo param);
    DOSHelmOperationPo rollbackRelease(DOSReleaseParamVo param);
    DOSHelmOperationPo uninstallRelease(DOSReleaseParamVo param);

    /**
     * @Author heyabo
     * @Description 根据项目分组查询release的数量
     * @Date 10:41 2022/8/26
     * @Param []
     * @return java.util.List<com.devops.admin.po.DOSReleaseCountPo>
     **/
    List<HashMap<String,Object>> getGroupRelease();

    /**
     * 检查release重启的权限 目前只有uat环境的release才能重启
     * @param releaseId
     */
    void checkRestartPermission(Integer releaseId);

    /**
     * @Author heyabo
     * @Description 根据项目id获取release
     * @Date 13:40 2022/9/9
     * @Param [projectId]
     * @return java.util.List<com.devops.admin.po.DOSReleasePo>
     **/
    List<DOSReleasePo> getReleasesByProjectId(Integer projectId);

    /**
     * @Author heyabo
     * @Description 获取image或者release的镜像和tag
     * @Date 11:38 2022/11/21
     * @Param [valuesVo]
     * @return java.lang.String
     **/
    String getImageTag(DOSReleaseValuesVo valuesVo);

    /**
     * @Author heyabo
     * @Description 根据项目id和环境类型id查询release集合
     * @Date 09:52 2023/1/4
     * @Param [projectId]
     * @return java.util.List<com.devops.admin.po.DOSReleasePo>
     **/
    List<DOSReleasePo> selectReleaseListByProjectIdAndEnvType(DOSReleaseVo releaseVo);
}
